<?php

	
	include '../../lib/common/dbRoutines.php';
	include '../../lib/dao/WordDao.php';
	/*header('Content-type: text/html; charset=utf-8');*/
	
	$conn = getDbConnection();
	$wordDao = new WordDao($conn);
	$words = array();
	
	
	//string with word separated by new line
	//$all_words = iconv("UTF-8", "windows-1251", $_POST['all_words']); 
	$all_words = $_POST['all_words']; 
	
	//wordon which was a click
	//$current_word = iconv("UTF-8", "windows-1251", $_POST['current_word']);
	$current_word = $_POST['current_word'];
	
	$temp = split("\n", $all_words);
	
	foreach($temp as $key => $val){
		//associative array, word is a key.
		$words[$val] = 1;
	}
	
	echo $wordDao -> select_word($_POST['complexity'], $current_word, &$words);
?>
